/**
 * Created by huhai on 17/6/29.
 */
let path = require('path')
const webpack = require("webpack");

console.log("当前的目录是", __dirname)
let HtmlWebpackPlugin = require('html-webpack-plugin');
let dist =path.resolve(__dirname,"dist")

module.exports = {
  entry: './big_area_map/src/main.js',
  output:{
    path: dist,
    filename:"bundle.js"
  },
  resolve: {
    extensions: ['.js','.json'],
    alias: {
      'jquery': 'jquery/src/jquery',
      'art-template': 'art-template/lib/template-web.js'
    }
  },
  devtool: "source-map",
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /(node_modules|bower_components)/,
        use:[{
          loader: 'babel-loader'
        }]
      },
      {
        test: /\.css$/,
        exclude: /(node_modules|bower_components)/,
        use:[{
          loader: "style-loader"
        },{
          loader: 'css-loader',
          options: {
            minimize: true,
            sourceMap: false
          }
        }]
      },
      {
        test: /\.(png|jpg|gif)$/,
        exclude: /(node_modules|bower_components)/,
        use:[{
          loader: 'url-loader',
          options: {
            limit: 8192
          }
        }]
      },
      {
        test: /\.scss$/,
        exclude: /(node_modules|bower_components)/,
        use:[{
          loader: "style-loader" // creates style nodes from JS strings
        }, {
          loader: "css-loader", // translates CSS into CommonJS
          options: {
            minimize: true,
            sourceMap: false
          }
        }, {
          loader: "sass-loader" // compiles Sass to CSS
        }]
      },
      {
        test: /\.html/,
        exclude: /(node_modules|bower_components)/,
        use:[{
          loader: "html-loader" // creates style nodes from JS strings
        }]
      }
    ]
  },
  devServer: {
    contentBase: dist,
    compress: true,
    port: 3000,
    proxy: {
      '/mock': {
        target: 'http://127.0.0.1:3090',
        changeOrigin: true,
        pathRewrite: {
          '^/mock': '/mock'
        }
      }
    }
  },
  plugins: [
    new HtmlWebpackPlugin({
      title:"图",
      template: "./big_area_map/index_detail.html"
    })
  ]
}